package com.food.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.food.dao.service.RecipeService;
import com.food.model.Recipe;

@WebServlet("/recipe/CountryRecipe")
public class CountryRecipe extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}


	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		int countryid = Integer.parseInt(request.getParameter("countryid"));
		
		RecipeService recipeService = new RecipeService();
		Recipe recipe = new Recipe();
		recipe.setCountryid(countryid);
		List<Recipe> list = recipeService.findRecipeByCountry(recipe);
		
		request.setAttribute("recipe_show", list);
		RequestDispatcher rd = request
				.getRequestDispatcher("/recipe/searchRecipe.jsp");
		rd.forward(request, response);
		return;
		
		
		
	}

}
